package yanyan.com.tochar.dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import java.util.List;

import androidx.annotation.NonNull;
import yanyan.com.tochar.R;
import yanyan.com.tochar.adpter.CommonListAdapter;
import yanyan.com.tochar.adpter.DiaLogListAdapter;
import yanyan.com.tochar.beans.HomeListBean;
import yanyan.com.tochar.beans.MyAppInfo;

public class ListDialog extends Dialog {
    private TextView title;
    private ListView list;
    private List<PackageInfo> listBeans;
    private String titleStr;
    private Selected selected;

    public ListDialog(@NonNull Context context,String titleStr,List<PackageInfo> listBeans,Selected selected) {
        super(context);
        setContentView(R.layout.dialog_list);
        title=findViewById(R.id.list_dialog_title);
        list=findViewById(R.id.list_dialog_list);

        title.setText(titleStr);
        this.selected=selected;
        DiaLogListAdapter diaLogListAdapter=new DiaLogListAdapter(context,listBeans);
        list.setAdapter(diaLogListAdapter);

        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                selected.getAppInfo(position);
                dismiss();
            }
        });
    }





    public interface Selected{
        public void getAppInfo(int position);
    }



}
